<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	if(IS_POST){
    		$data = D('Admin_member')->where(array('mail'=>I('post.username','','trim')))->find();
    		if(empty($data))
    		{
    			$this->error('帐号不存在！');
    		}
    		elseif($data['password']!=md5(I('post.password')))
    		{
    			$this->error('密码不正确！');
    		}
    		else{
    			$_SESSION['member'] = $data;
    			$_SESSION['apps'] = D('App')->where(array('member_id'=>$data['id']))->select();
    			$_SESSION['app'] = $_SESSION['apps'][$data['index_app']];
    			redirect('/Index');
    		}
    	}else{
    		$this->display();
    	}
    }
    public function logout(){
    	unset($_SESSION['member']);
    	unset($_SESSION['apps']);
    	unset($_SESSION['app']);
    	redirect('/Login');
    }
    public function register(){
    	if(IS_POST){
    		
    	}else{
    		$this->display();
    	}
    }
}